<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop">
          <div style="width:100%">
              <div style="width:100%;float:left">
                  <table style="font-size:12px;width:100%" class="table1style">
                      <tr>
                          <td align="center">快速检索</td>
                          <td>
                              <el-input v-model.trim="txtsearch" placeholder="药物代码|名称|英文|whonet代码|输入码" @keyup.enter.native="QueryData" clearable style="width:260px"></el-input>
                          </td>
                          <td>
                              <el-button icon="el-icon-search" @click="QueryData" v-has="'PINQUERY'" type="primary" :disabled="changeflag">查询</el-button>

                              <el-button icon="el-icon-plus" @click="btnAddList" v-has="'PADD'" :disabled="changeflag">新增</el-button>

                              <el-button icon="el-icon-delete" @click="btnRemoveList" v-has="'PDELETE'" :disabled="changeflag">删除</el-button>

                              <el-button icon="el-icon-document" @click="saveRecord" :disabled="!changeflag">保存</el-button>

                              <el-button icon="el-icon-close" @click="btnCancel" :disabled="!changeflag">取消</el-button>

                              <el-button icon="el-icon-sort" @click="btnSortList" v-has="'PSORT'" :disabled="changeflag">排序</el-button>

                              <el-button icon="el-icon-download" @click="btnExportCsv" v-has="'PEXPORT'" :disabled="changeflag">导出</el-button>

                              <el-button icon="el-icon-upload2" @click="importMed" :disabled="changeflag" style="margin-right: 10px;">导入</el-button>
                              <div class="upload-button">
                                  <el-upload ref="upload" 
                                      :action="url" accept=".xlsx" :on-change="fileChange" :show-file-list="showFile"
                                      :data="updata" :http-request="uploadOpt">
                                      <el-button size="small" plain>选择文件</el-button>
                                      <!-- <div slot="tip" class="el-upload__tip">只能上传DAT(*dat)文件，且不超过10M</div> -->
                                  </el-upload>
                              </div>
                              <el-button icon="el-icon-upload2" @click="btnImportCsv" size="small" :disabled="changeflag">导入 Whonet</el-button>
                          </td>
                      </tr>
                  </table>
              </div>
          </div>
      </div>
      <div class="pagecenter">
          <div class="middle-center">
              <vxe-table :data.sync="labMedData" :loading="loading" :keyboard-local-config="keyLocalConfig" :cell-class-name="labmedcellClassName" :row-class-name="rowClassName" :sort-config="{trigger: 'cell'}" @current-change="currentChangeEvent" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row highlight-hover-column ref="xTable" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                  <vxe-table-column type="index" title="NO." width="40" align="center"></vxe-table-column>
                  <vxe-table-column field="medcode" title="药物代码" width="60" sortable align="center"></vxe-table-column>
                  <vxe-table-column field="medname" title="药物名称" width="150" sortable></vxe-table-column>
                  <vxe-table-column field="medname_en" title="药物英文" width="110" sortable></vxe-table-column>
                  <vxe-table-column field="seq" title="序号" width="45" sortable align="center"></vxe-table-column>
                  <vxe-table-column field="medconc" title="药物浓度" width="70" sortable></vxe-table-column>
                  <vxe-table-column field="kbny" title="KB耐药<=" width="70" sortable></vxe-table-column>
                  <vxe-table-column field="kbmg" title="KB敏感>=" width="70" sortable></vxe-table-column>
                  <vxe-table-column field="kbrange" title="KB参考范围" width="80" sortable></vxe-table-column>
                  <vxe-table-column field="micrange" title="MIC参考范围" width="80" sortable></vxe-table-column>
                  <vxe-table-column field="micmg" title="MIC敏感<=" width="70" sortable></vxe-table-column>
                  <vxe-table-column field="micny" title="MIC耐药>=" width="70" sortable></vxe-table-column>
                  <vxe-table-column field="inputcode" title="录入码" width="70" sortable></vxe-table-column>
                  <vxe-table-column field="whocode" title="WHONET代码" width="100" sortable></vxe-table-column>
                  <vxe-table-column field="whocode_kb" title="WHONET_KB代码" width="120" sortable></vxe-table-column>
                  <vxe-table-column field="whocode_mic" title="WHONET_MIC代码" width="120" sortable></vxe-table-column>
                  <vxe-table-column field="whocode_etest" title="WHONET_ETEST代码" width="120" sortable></vxe-table-column>
                  <vxe-table-column field="statcode" title="统计代码" width="80" sortable></vxe-table-column>
                  <vxe-table-column field="medconc_blood" title="血药浓度" width="80" sortable></vxe-table-column>
                  <vxe-table-column field="medconc_urine" title="尿药浓度" width="80" sortable></vxe-table-column>
                  <vxe-table-column field="dosage1" title="用法1" width="90" sortable></vxe-table-column>
                  <vxe-table-column field="dosage2" title="用法2" width="90" sortable></vxe-table-column>
                  <vxe-table-column field="dosage3" title="用法3" width="90" sortable></vxe-table-column>
                  <vxe-table-column field="externalcode1" title="外部代码1" width="100" sortable></vxe-table-column>
                  <vxe-table-column field="externalcode2" title="外部代码2" width="100" sortable></vxe-table-column>
                  <vxe-table-column field="externalcode3" title="外部代码3" width="100" sortable></vxe-table-column>
                  <!-- <vxe-table-column field="whonetcolidx" title="WHONET固定列" width="160" sortable></vxe-table-column> -->
                  <vxe-table-column field="whonetresname" title="WHONET耐药机制" width="160" sortable></vxe-table-column>
                  <vxe-table-column field="stopflag" title="停用标志" width="80" sortable></vxe-table-column>
                  <vxe-table-column field="medclass2code" title="二级分类" width="100" sortable></vxe-table-column>
                  <vxe-table-column field="medclass2name" title="二级分类中文" width="100" sortable></vxe-table-column>
                  <vxe-table-column field="medclass3code" title="三级分类" width="100" sortable></vxe-table-column>
                  <vxe-table-column field="medclass3name" title="三级分类中文" width="100" sortable></vxe-table-column>
                  <vxe-table-column field="i2sdd" title="中介转换为SDD" width="110" sortable></vxe-table-column>
                  <vxe-table-column field="ecvs" title="流行病界值" width="90" sortable></vxe-table-column>
                  <vxe-table-column field="guidelines" title="Guidelines" width="90" sortable></vxe-table-column>
              </vxe-table>
          </div>
          <div class="middle-right">
              <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
                  <el-tab-pane label="基本信息" name="first">
                      <div style="height:100%;overflow:auto">
                          <el-form ref="LabMedInfo" :model="LabMedInfo" @submit.native.prevent :disabled="!havedata">
                              <table class="formtablestyle">
                                  <tr>
                                      <td>
                                          <font color="red">药物代码</font>
                                      </td>
                                      <td>
                                          <el-input v-model="LabMedInfo.medcode" placeholder="" :disabled="dismedcode" ref="autofocus1" @keyup.enter.native="Funautofocus('autofocus1')" @input="hasChange('medcode')"></el-input>
                                      </td>
                                      <td>KB耐药&lt;=</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.kbny" placeholder="" ref="autofocus11" @keyup.enter.native="Funautofocus('autofocus11')"   @change="calcMedRange('kbny')"></el-input>
                                      </td>
                                      <td>MIC耐药&gt;=</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.micny" placeholder="" ref="autofocus21" @keyup.enter.native="Funautofocus('autofocus21')"  @change="calcMedRange('micny')"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>
                                          <font color="red">药物名称</font>
                                      </td>
                                      <td>
                                          <el-input type="text" v-model="LabMedInfo.medname" placeholder="" ref="autofocus2" @keyup.enter.native="Funautofocus('autofocus2')" @change="hasChange"></el-input>
                                      </td>

                                      <td>KB敏感&gt;=</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.kbmg" placeholder="" ref="autofocus12" @keyup.enter.native="Funautofocus('autofocus12')" @change="calcMedRange('kbmg')"></el-input>
                                      </td>
                                      <td>MIC敏感&lt;=</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.micmg" placeholder="" ref="autofocus22" @keyup.enter.native="Funautofocus('autofocus22')" @change="calcMedRange('micmg')"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>药物英文</td>
                                      <td>
                                          <el-input type="text" v-model="LabMedInfo.medname_en" placeholder="" ref="autofocus3" @keyup.enter.native="Funautofocus('autofocus3')" @change="hasChange"></el-input>
                                      </td>
                                      <td>KB参考范围</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.kbrange" placeholder="" ref="autofocus13" @keyup.enter.native="Funautofocus('autofocus13')" @change="hasChange"></el-input>
                                      </td>

                                      <td>MIC参考范围</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.micrange" placeholder="" ref="autofocus23" @keyup.enter.native="Funautofocus('autofocus23')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>输入码</td>
                                      <td>
                                          <el-input type="text" v-model="LabMedInfo.inputcode" placeholder="" ref="autofocus4" @keyup.enter.native="Funautofocus('autofocus4')" @change="hasChange"></el-input>
                                      </td>
                                      <td>kb中介</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.kbzj" placeholder="" ref="autofocus14" @keyup.enter.native="Funautofocus('autofocus14')" @change="hasChange"></el-input>
                                      </td>
                                      <td>
                                          <font color="red">统计代码</font>
                                      </td>
                                      <td>
                                          <el-input type="text" v-model="LabMedInfo.statcode" placeholder="" ref="autofocus24" @keyup.enter.native="Funautofocus('autofocus24')" @change="hasChange"></el-input>
                                      </td>

                                  </tr>
                                  <tr>
                                      <td>药物浓度</td>
                                      <td>
                                          <el-input type="text" v-model="LabMedInfo.medconc" placeholder="" ref="autofocus5" @keyup.enter.native="Funautofocus('autofocus5')" @change="hasChange"></el-input>
                                      </td>
                                      <td>外部代码1</td>
                                      <td>
                                          <el-select v-model="LabMedInfo.externalcode1" ref="autofocus15" filterable @keyup.enter.native="Funautofocus('autofocus15')" style="width:100%" @change="hasChange">
                                              <el-option v-for="(item,index) in ExternalCode1Option" :key="index" :label="item.label" :value="item.value"></el-option>
                                          </el-select>
                                      </td>
                                      <td>WHONET代码</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.whocode" placeholder="" ref="autofocus25" @keyup.enter.native="Funautofocus('autofocus25')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>尿药浓度</td>
                                      <td>
                                          <el-input type="text" v-model="LabMedInfo.medconc_urine" placeholder="" ref="autofocus6" @keyup.enter.native="Funautofocus('autofocus6')" @change="hasChange"></el-input>
                                      </td>
                                      <td>外部代码2</td>
                                      <td>
                                          <el-select v-model="LabMedInfo.externalcode2" ref="autofocus16" filterable @keyup.enter.native="Funautofocus('autofocus16')" style="width:100%" @change="hasChange">
                                              <el-option v-for="(item,index) in ExternalCode2Option" :key="index" :label="item.label" :value="item.value"></el-option>
                                          </el-select>
                                      </td>

                                      <td>WHONET_KB代码</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.whocode_kb" placeholder="" ref="autofocus26" @keyup.enter.native="Funautofocus('autofocus26')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>血药浓度</td>
                                      <td>
                                          <el-input type="text" v-model="LabMedInfo.medconc_blood" placeholder="" ref="autofocus7" @keyup.enter.native="Funautofocus('autofocus7')" @change="hasChange"></el-input>
                                      </td>

                                      <td>外部代码3</td>
                                      <td>
                                          <el-select v-model="LabMedInfo.externalcode3" ref="autofocus17" filterable @keyup.enter.native="Funautofocus('autofocus17')" style="width:100%" @change="hasChange">
                                              <el-option v-for="(item,index) in ExternalCode3Option" :key="index" :label="item.label" :value="item.value"></el-option>
                                          </el-select>
                                      </td>

                                      <td>WHONET_MIC代码</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.whocode_mic" placeholder="" ref="autofocus27" @keyup.enter.native="Funautofocus('autofocus27')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>二级分类</td>
                                      <td>
                                          <el-input type="text" v-model.trim="LabMedInfo.medclass2code" placeholder="" ref="autofocus8" @keyup.enter.native="Funautofocus('autofocus8')" @change="hasChange"></el-input>
                                      </td>
                                      <td>三级分类</td>
                                      <td>
                                          <el-input type="text" v-model.trim="LabMedInfo.medclass3code" placeholder="" ref="autofocus18" @keyup.enter.native="Funautofocus('autofocus18')" @change="hasChange"></el-input>
                                      </td>
                                      <td>WHONET_ETEST代码</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.whocode_etest" placeholder="" ref="autofocus28" @keyup.enter.native="Funautofocus('autofocus28')" @change="hasChange"></el-input>
                                      </td>

                                  </tr>
                                  <tr>
                                      <td>二级分类中文</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.medclass2name" placeholder="" ref="autofocus9" @keyup.enter.native="Funautofocus('autofocus9')" @change="hasChange"></el-input>
                                      </td>
                                      <td>三级分类中文</td>
                                      <td>
                                          <el-input type="text" v-model.trim="LabMedInfo.medclass3name" placeholder="" ref="autofocus19" @keyup.enter.native="Funautofocus('autofocus19')" @change="hasChange"></el-input>
                                      </td>
                                      <td>WHONET耐药机制</td>
                                      <td>
                                          <el-select v-model="LabMedInfo.whonetrescode" clearable ref="autofocus29" @keyup.enter.native="Funautofocus('autofocus29')" style="width:100%" @change="hasChange">
                                              <el-option v-for="item in whonetResistOption" :key="item.value" :value="item.value" :label="item.label">
                                                  <span style="float: left">{{ item.label }}</span>
                                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
                                              </el-option>
                                          </el-select>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>Guidelines</td>
                                      <td>
                                          <el-select v-model="LabMedInfo.guidelines" placeholder="请选择Guidelines" style="width: 100%" ref="autofocus10" @keyup.enter.native="Funautofocus('autofocus10')" clearable @change="hasChange">
                                              <el-option v-for="item in guidelinesList" :key="item.guidelines" :label="item.guidelines" :value="item.guidelines"></el-option>
                                          </el-select>
                                      </td>
                                      <td>流行病界值</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.ecvs" placeholder="" ref="autofocus20" @keyup.enter.native="Funautofocus('autofocus20')" @change="hasChange"></el-input>
                                      </td>
                                      <td>WHONET导出计算公式</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.whocode_calc" placeholder="" ref="autofocus30" @keyup.enter.native="Funautofocus('autofocus30')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>中介转换为SDD</td>
                                      <td>
                                          <el-input v-model="LabMedInfo.i2sdd" placeholder="" ref="autofocus31" @keyup.enter.native="Funautofocus('autofocus31')" @change="hasChange"></el-input>
                                      </td>
                                      <td>打印序号</td>
                                      <td>
                                          <el-input type="number" v-model.number="LabMedInfo.seq" placeholder="" ref="autofocus32" @keyup.enter.native="Funautofocus('autofocus32')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>用法1</td>
                                      <td colspan="5">
                                          <el-input type="text" v-model="LabMedInfo.dosage1" placeholder="" ref="autofocus33" @keyup.enter.native="Funautofocus('autofocus33')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>用法2</td>
                                      <td colspan="5">
                                          <el-input type="text" v-model="LabMedInfo.dosage2" placeholder="" ref="autofocus34" @keyup.enter.native="Funautofocus('autofocus34')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td>用法3</td>
                                      <td colspan="5">
                                          <el-input type="text" v-model="LabMedInfo.dosage3" placeholder="" ref="autofocus35" @keyup.enter.native="Funautofocus('autofocus35')" @change="hasChange"></el-input>
                                      </td>
                                  </tr>
                                  <tr>
                                      
                                      <td>停用标志</td>
                                      <td>
                                          <el-checkbox true-label="1" false-label="0" v-model="LabMedInfo.stopflag" ref="autofocus36" @keyup.enter.native="Funautofocus('autofocus36')" @change="hasChange"></el-checkbox>
                                      </td>
                                      <td>是否重点抗生素</td>
                                      <td>
                                          <el-checkbox v-model="LabMedInfo.isimportant" true-label="1" false-label="0" ref="autofocus37" @keyup.enter.native="Funautofocus('autofocus37')" @change="hasChange"></el-checkbox>
                                      </td>
                                  </tr>
                              </table>
                          </el-form>
                      </div>
                  </el-tab-pane>
                  <el-tab-pane label="折点" name="second">
                      <div style="height: 73px ">
                          <el-tag style="height: 70px;width:100%;font-size:14px;font-weight:550">提示:<br style="padding-left:10px">1.当使用Etest法试验时，仍沿用KB法参数。但是设置的【KB耐药】取值要大于【KB敏感】取值。<br style="padding-left:10px">2.KB法,MIC法的耐药、敏感默认采用&lt;=、&gt;=，若想设置&lt;、&gt;请在取值栏手动输入&lt;、&gt;。
                          </el-tag>
                      </div>
                      <div class="labmed-content" style="height:calc( 100% - 73px )">
                          <vxe-table ref="psetTable" :data.sync="labmedref" :loading="medrefloading" border height="100%" size="mini" stripe resizable highlight-current-row show-header-overflow show-overflow :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" header-align="center" :edit-config="{trigger: 'click', mode: 'row', showIcon: false}" :row-class-name="RowClassName" @cell-dblclick="dbLab_medref" :key="labmedrefkey">
                              <vxe-table-column type="index" title="NO. " width="50" align="center"></vxe-table-column>
                              <vxe-table-column field="orgcode" title="细菌代码(双击开窗)" width="120"></vxe-table-column>
                              <vxe-table-column field="germkindname" title="菌科名称" width="140"></vxe-table-column>
                              <vxe-table-column field="germgroupname" title="菌属名称" width="140"></vxe-table-column>
                              <vxe-table-column field="rpt_itemname" title="细菌名称" width="140">
                                  <template v-slot="{row}">
                                      <span v-if="row.isgermgroup !='1' && row.isgermgroup !='2'">{{row.rpt_itemname}}</span>
                                  </template>
                              </vxe-table-column>
                              <!-- <vxe-table-column field="isgermgroup" title="菌属/菌科" width="80" align="center">
                                  <template v-slot="{row}">
                                      {{row.isgermgroup=='1'?"菌属":(row.isgermgroup=='2'?'菌科':'')}}
                                  </template>
                              </vxe-table-column> -->
                              <vxe-table-column field="testmethod" title="测试方法" width="80" :edit-render="{name: 'select',options:$opt.testmethod,events: {change: testMethodChange}}" align='center'></vxe-table-column>
                              <vxe-table-column field="guidelines" title="使用标准" :edit-render="{name: 'input',autoselect:true}" width="80" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.guidelines" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'potency')" @change="hasChange"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="potency" title="药物浓度" :edit-render="{name: 'input',autoselect:true}" width="80" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.potency" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'kbny')" @change="hasChange"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="kbny" title="KB耐药<=" :edit-render="{name: 'input',autoselect:true}" width="80" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.kbny" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'kbmg')" @change="CalcRange($event,row,'kbny')"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="kbmg" title="KB敏感>=" :edit-render="{name: 'input',autoselect:true}" width="80" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.kbmg" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'kbzj')" @change="CalcRange($event,row,'kbmg')"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="kbzj" title="KB中敏" :edit-render="{name: 'input',autoselect:true}" width="80" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.kbzj" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'micny')" @change="hasChange"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="micny" title="MIC耐药>=" :edit-render="{name: 'input',autoselect:true}" width="89" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.micny" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'micmg')" @change="CalcRange($event,row,'micny')"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="micmg" title="MIC敏感<=" :edit-render="{name: 'input',autoselect:true}" width="89" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.micmg" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'miczj')" @change="CalcRange($event,row,'micmg')"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="miczj" title="MIC中敏" :edit-render="{name: 'input',autoselect:true}" width="89" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.miczj" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'kbrange')" @change="hasChange"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="kbrange" title="KB参考范围" :edit-render="{name: 'input',autoselect:true}" width="89" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.kbrange" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'micrange')" @change="hasChange"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="micrange" title="MIC参考范围" :edit-render="{name: 'input',autoselect:true}" width="109" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.micrange" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'ecvs')" @change="hasChange"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="ecvs" title="流行病学界值" :edit-render="{name: 'input',autoselect:true}" width="109" align='center'>
                                  <template v-slot:edit="{ row }">
                                      <el-input v-model="row.ecvs" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'i2sdd')" @change="hasChange"></el-input>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="i2sdd" title="中介转换为SDD" width="109" align="center">
                                  <template v-slot="{row}">
                                      <el-checkbox v-model="row.i2sdd" true-label='1' false-label="0" @change="hasChange"></el-checkbox>
                                  </template>
                                  <!-- <template v-slot:edit="{ row }">
                                      <el-input v-model="row.i2sdd" @keyup.enter.native="$refs.psetTable.setActiveCell(row,'medcode')" @change="hasChange"></el-input>
                                  </template> -->
                              </vxe-table-column>
                               <vxe-table-column field="isimportant" title="是否重点抗生素" width="109" align="center">
                                  <template v-slot="{row}">
                                      <el-checkbox v-model="row.isimportant" true-label='1' false-label="0" @change="hasChange"></el-checkbox>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="medcode" title="药物代码" width="80"></vxe-table-column>
                              <vxe-table-column field="specimen_code" title="标本类型(双击开窗)" width="150">
                                               <template v-slot="{row}">
                                          <rm-ddl-common ref="ddlspecimen" datatype="specimenaddall" dataname="标本类型" v-model="row.specimen_code" width="150px"  @change="hasChange"></rm-ddl-common>
                                          <!-- <el-input v-model="row.specimen_code" width="150px" @dblclick="openSpecDlg"></el-input>  -->
                                               </template>
                              </vxe-table-column>
                              <template v-slot:fix>
                                  <div style="font-size:17px;padding:3px;background-color:#fff;overflow:auto;text-align:left">
                                      <el-button class="el-button--310" @click="OpenDialog(1)">新增明细</el-button>
                                      <el-button class="el-button--310" @click="OpenDialog(2)">删除明细</el-button>
                                      <!-- <el-button class="el-button--310" @click="OpenDialog(3)">保存明细</el-button> -->
                                      <el-button class="el-button--310" @click="OpenDialog(4)">导入折点</el-button>
                                  </div>
                              </template>
                          </vxe-table>
                      </div>
                  </el-tab-pane>
              </el-tabs>
          </div>
      </div>
      <!--折点细菌弹窗-->
      <el-dialog width="1000px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="选择细菌代码" :visible.sync="rptitemgermVisible" :destroy-on-close="true">
          <table style="width:100%" class="table1style">
              <tr>
                  <td>
                      <el-radio-group v-model="geramradio" @change="geramradioChange">
                          <el-radio :label="1">菌科</el-radio>
                          <el-radio :label="2">菌属</el-radio>
                          <el-radio :label="3">细菌</el-radio>
                      </el-radio-group>
                  </td>
              </tr>
          </table>
          <rm-pop-common @change="geramSelect" @cancel="rptitemgermVisible=false;" :multiple="false" :datatype="datetype" :key="popkey"></rm-pop-common>
      </el-dialog>
      <!--顶部导入whonet-->
      <el-dialog width="1055px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="Whonet 抗生素字典" :visible.sync="WhonetVisible" :destroy-on-close="true" :show-close="false">
          <div class="whone-top">
              <span>
                  Guidelines：
                  <el-select v-model="whonetParam.guidelines" placeholder="请选择Guidelines" @change="guidelinesChange" style="width: 100%">
                      <el-option v-for="item in guidelinesList" :key="item.guidelines" :label="item.guidelines" :value="item.guidelines"></el-option>
                  </el-select>
              </span>
              <span class="input-suffix" style="margin-left: 20px;">
                  查找：
                  <el-input placeholder="请输入抗生素英文名称, WHON5_CODE, 抗生素中文名称" v-model="whonetParam.filterParam" @keyup.enter.native="filterData"></el-input>
              </span>
              <span style="margin-left: 20px;">
                  <el-button @click="saveLabmed">确定</el-button>
              </span>
              <span style="margin-left: 20px;">
                  <el-button @click="cancelLabmed">取消</el-button>
              </span>
          </div>
          <div class="whone-bottom">
              <vxe-table ref="whoneTable" :data.sync="whonetList" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border height="100%" highlight-current-row how-header-overflow resizable show-overflow size="mini" stripe header-align="center" @cell-dblclick="dbLab_medref" @select-change="selectChangeEvent">
                  <vxe-table-column type="selection" align="center" width="60"></vxe-table-column>
                  <vxe-table-column field="dealname" title="操作" width="60"></vxe-table-column>
                  <vxe-table-column field="statcode" title="LIS7抗生素代码" width="140">
                      <template v-slot="{row}">
                          <el-input v-if="row.dealname != '新增'" v-model="row.statcode" disabled></el-input>
                          <el-input v-else v-model="row.statcode"></el-input>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="antibiotic" title="抗生素英文名称" width="140"></vxe-table-column>
                  <vxe-table-column field="antibiotic_cn" title="抗生素中文名称" width="140"></vxe-table-column>
                  <vxe-table-column field="potency" title="药物浓度" width="100"></vxe-table-column>
                  <vxe-table-column field="whon5_code" title="WHON5_CODE" width="120"></vxe-table-column>
                  <vxe-table-column field="who_code" title="WHO_CODE" width="120"></vxe-table-column>
                  <vxe-table-column field="whon4_code" title="WHON4_CODE" width="120"></vxe-table-column>
                  <vxe-table-column field="guidelines" title="GUIDELINES" width="120"></vxe-table-column>
                  <vxe-table-column field="class" title="CLASS" width="160"></vxe-table-column>
                  <vxe-table-column field="kbny" :title="whoDrugField.KBNY" width="89"></vxe-table-column>
                  <vxe-table-column field="kbzj" :title="whoDrugField.Kbzj" width="89"></vxe-table-column>
                  <vxe-table-column field="kbmg" :title="whoDrugField.Kbmg" width="89"></vxe-table-column>
                  <vxe-table-column field="micny" :title="whoDrugField.Micny" width="89"></vxe-table-column>
                  <vxe-table-column field="micmg" :title="whoDrugField.Micmg" width="89"></vxe-table-column>
              </vxe-table>
          </div>
      </el-dialog>
      <!--Tab折点导入-->
      <el-dialog width="1055px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="Whonet 抗生素折点" :visible.sync="whoDrugVisible" :destroy-on-close="true" :show-close="false">
          <div class="whone-top">
              <span>
                  Guidelines：
                  <el-select v-model="whodrugParam.guidelines" placeholder="请选择Guidelines" @change="guidelinesChange" style="width: 100%">
                      <el-option v-for="item in guidelinesList" :key="item.guidelines" :label="item.guidelines" :value="item.guidelines"></el-option>
                  </el-select>
              </span>
              <span>
                  Testmethod：
                  <el-select v-model="whodrugParam.testmethod" placeholder="请选择Testmethod" clearable @change="filterWhodrugChange" style="width: 100%">
                      <el-option v-for="item in testmethodList" :key="item.testmethod" :label="item.testmethod" :value="item.testmethod"></el-option>
                  </el-select>
              </span>
              <span>
                  Org Code：
                  <rm-ddl-common v-model="whodrugParam.orgcode" @change="orgCodeChange" :multiple="false" datatype="rptitemgermflag2"></rm-ddl-common>
              </span>
              <span style="margin-left: 60px;">
                  <el-button @click="saveWhodrug">确定</el-button>
              </span>
              <span style="margin-left: 20px;">
                  <el-button @click="cancelWhodrug">取消</el-button>
              </span>
          </div>
          <div class="whone-bottom">
              <vxe-table ref="whoneDrugTable" :data.sync="whoDrugList" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border height="100%" header-align="center" highlight-current-row how-header-overflow resizable show-overflow size="mini" stripe>
                  <vxe-table-column type="selection" width="60" align="center"></vxe-table-column>
                  <vxe-table-column field="guidelines" title="Guidelines" width="100"></vxe-table-column>
                  <vxe-table-column field="testmethod" title="Testmethod" width="100"></vxe-table-column>
                  <vxe-table-column field="potency" title="Potency" width="100"></vxe-table-column>
                  <vxe-table-column field="org_code" title="Org Code" width="100"></vxe-table-column>
                  <vxe-table-column field="site_inf" title="Site Inf" width="100"></vxe-table-column>
                  <vxe-table-column field="ref_table" title="Ref Table" width="100"></vxe-table-column>
                  <vxe-table-column field="ref_seq" title="Ref Seq" width="80"></vxe-table-column>
                  <vxe-table-column field="whon5_code" title="Whon5 Code" width="100"></vxe-table-column>
                  <vxe-table-column field="whon5_test" title="Whon5 Test" width="100"></vxe-table-column>
                  <vxe-table-column field="disk_r" title="disk R" width="80"></vxe-table-column>
                  <vxe-table-column field="disk_i" title="disk I" width="80"></vxe-table-column>
                  <vxe-table-column field="disk_s" title="disk S" width="80"></vxe-table-column>
                  <vxe-table-column field="mic_s" title="mic S" width="80"></vxe-table-column>
                  <vxe-table-column field="mic_r" title="mic R" width="80"></vxe-table-column>
                  <vxe-table-column field="organism_cn" title="细菌名称" width="180"></vxe-table-column>
              </vxe-table>
          </div>
      </el-dialog>
      <!---抗生素字典排序---->
      <el-dialog width="700px" title="抗生素字典排序" :visible.sync="SortinnerVisible" v-el-drag-dialog :close-on-click-modal="false" @close="SortCancel">
          <div style="width:100%;height:500px;position:relative;">
              <div style=" overflow: visible;position:absolute;right:145px;left:0;height:100%">
                  <vxe-table show-overflow ref="xTable1" height="auto" class="mytable-style" :loading="xTable1loading" :select-config="{reserve: true}" :cell-class-name="cellClassName" :sort-config="{trigger: 'cell'}" :mouse-config="{selected: true}" :data.sync="tableData1" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,activeMethod:cellinputseq,showIcon:false}" @current-change="SortCurrentChangeEvent">
                      <vxe-table-column type="index" title="NO." width="50" align="center"></vxe-table-column>
                      <vxe-table-column field="medcode" title="药物代码" width="80" header-align="center" align="center"></vxe-table-column>
                      <vxe-table-column field="medname" title="药物名称" width="130" header-align="center"></vxe-table-column>
                      <vxe-table-column field="medname_en" title="药物英文" width="130" header-align="center"></vxe-table-column>
                      <vxe-table-column field="seq" title="序号" width="80" sortable header-align="center" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                  </vxe-table>
              </div>
              <div style="width:140px;position:absolute;border:1px solid #CCC;height:100%;right:0px">
                  <table>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-checkbox label="手工输入序号" true-label="1" false-label="0" v-model="inputseq"></el-checkbox>
                          </td>
                      </tr>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-button icon="el-icon-document" @click="funSortListSave">保存</el-button>
                          </td>
                      </tr>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-button icon="el-icon-close" @click="SortCancel">取消</el-button>
                          </td>
                      </tr>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-button icon="el-icon-refresh" @click="SortShowData">刷新</el-button>
                          </td>
                      </tr>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-button icon="el-icon-top" @click="tabledatafirst">首位</el-button>
                          </td>
                      </tr>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-button icon="el-icon-top-right" @click="tabledataup">上移</el-button>
                          </td>
                      </tr>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-button icon="el-icon-bottom-right" @click="tabledatadown">下移</el-button>
                          </td>
                      </tr>
                      <tr>
                          <td class="sortbtnstyle">
                              <el-button icon="el-icon-bottom" @click="tabledatalast">末位</el-button>
                          </td>
                      </tr>
                  </table>
              </div>
          </div>
      </el-dialog>
  </div>
</template>

<script type="text/javascript">
// import { format } from "path";
import XEUtils from "xe-utils";
import axios from "axios";
export default {
  name: "LIS820",
  data() {
      return {
          inputseq: "",
          dialogTableVisible: false,
          tableData1: [],
          loading: false,
          xTable1loading: false,
          txtsearch: "",
          medcode: "",
          operatetype: "", //0删除 1新增 2.修改
          message: "",
          datetype: "labgermkind",
          geramradio: 1,
          datetitle: "请选择菌科",
          currRowIndex: 0,
          dismedcode: false,
          SortinnerVisible: false,
          medrefloading: false,
          dialogbactMedKind: false,
          activeName: "first",
          labmedref: [],
          labmedrefkey: 0,
          LabMedInfo: {
              medcode: "",
              statcode: "",
              medname: "",
              stopflag: "",
              medname_en: "",
              medconc: "",
              inputcode: "",
              kbny: "",
              kbmg: "",
              micny: "",
              micmg: "",
              kbrange: "",
              micrange: "",
              whocode: "",
              whocode_kb: "",
              whocode_mic: "",
              whocode_etest: "",
              medconc_blood: "",
              medconc_urine: "",
              dosage1: "",
              dosage2: "",
              dosage3: "",
              externalcode1: "",
              externalcode2: "",
              externalcode3: "",
              whonetcolidx: 0,
              seq: 0,
              noprintrule: "",
              note: "",
              medclass2code: "",
              medclass2name: "",
              medclass3code: "",
              medclass3name: "",
              ecvs: "",
              i2sdd: "",
              kbzj: "",
              isimportant:"",
          },
          oldLabMedInfo: {
              medcode: "",
              statcode: "",
              medname: "",
              stopflag: "",
              medname_en: "",
              medconc: "",
              inputcode: "",
              kbny: "",
              kbmg: "",
              micny: "",
              micmg: "",
              kbrange: "",
              micrange: "",
              whocode: "",
              whocode_kb: "",
              whocode_mic: "",
              whocode_etest: "",
              medconc_blood: "",
              medconc_urine: "",
              dosage1: "",
              dosage2: "",
              dosage3: "",
              externalcode1: "",
              externalcode2: "",
              externalcode3: "",
              whonetcolidx: 0,
              seq: 0,
              noprintrule: "",
              note: "",
              medclass2code: "",
              medclass2name: "",
              medclass3code: "",
              medclass3name: "",
              ecvs: "",
              i2sdd: "",
              kbzj: "",
              isimportant:"",
          },
          selrow: {},
          poptableData: [],
          ExternalCode1Option: [],
          ExternalCode2Option: [],
          ExternalCode3Option: [],
          whonetResistOption: [],
          tablePage: {
              pageSize: 15,
          },
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
              isArrow: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          selectConfig: {
              tigger: "row",
          },
          tableColumn: [],
          rptitemgermVisible: false,
          detailrow: {},
          WhonetVisible: false,
          fwhonetList: [],
          whonetList: [],
          whonetParam: {
              guidelines: "CLSI18",
          },
          guidelinesList: [],
          whoDrugField: {
              KBNY: "clsi18_dr",
              Kbzj: "clsi18_di",
              Kbmg: "clsi18_ds",
              Micny: "clsi18_mr",
              Micmg: "clsi18_ms",
          },
          saveflag: false,
          whoDrugVisible: false,
          fwhoDrugList: [],
          whoDrugList: [],
          whodrugParam: {
              guidelines: "CLSI18",
          },
          testmethodList: [],
          txtmedkindsearch: "",
          RowMedKind: {},
          ModData: [],
          AddData: [],
          labmedkey: 0,
          labMedData: [],
          popkey: 0,
          changeflag: false,
          havedata: false,
          form: {},
          showFile: false,
          url: "",
          updata: { action: "LIS110-excel" }, 
          importNumtext: "",
          micrange:"",
          kbrange:"",
      };
  },

  created() {
      this.InitPage();
      this.ddlInitialList();
  },
  updated() {
      if (this.LabMedInfo.medname != "") {
          this.getinputcode();
      }
      //this.getkbvalue();
      //this.getmicvalue();
  },
  computed: {},
  methods: {
      initGuidelinesList() {
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "initguidelines",
                      guidelines: this.whonetParam.guidelines,
                  },
              })
              .then((response) => {
                  this.fwhonetList = XEUtils.clone(response.bactwhodruglist, true);
                  this.whonetList = response.bactwhodruglist;
                  this.whoDrugField = {
                      KBNY: this.whonetParam.guidelines.toLowerCase() + "_dr",
                      Kbzj: this.whonetParam.guidelines.toLowerCase() + "_di",
                      Kbmg: this.whonetParam.guidelines.toLowerCase() + "_ds",
                      Micny: this.whonetParam.guidelines.toLowerCase() + "_mr",
                      Micmg: this.whonetParam.guidelines.toLowerCase() + "_ms",
                  };
              })
              .catch((e) => {
                  this.loading = false;
                  console.log("error", e);
              });
      },
      //自动获取kb参考范围
      getkbvalue() {
          let nyval = "";
          let mgval = "";
          if (!!this.LabMedInfo.kbny) {
              nyval = "<=" + this.LabMedInfo.kbny;
          }
          if (!!this.LabMedInfo.kbmg) {
              mgval = ">=" + this.LabMedInfo.kbmg;
          }
          if (!!mgval && !!nyval) {
              this.$nextTick(() => {
                  if(this.kbrange){
                      this.LabMedInfo.kbrange=this.kbrange.replace("#S",this.LabMedInfo.kbmg).replace("#R",this.LabMedInfo.kbny);
                  }else {
                      this.LabMedInfo.kbrange = mgval + ";" + nyval;
                  }
              });
          } else if (!!mgval) {
              this.$nextTick(() => {
                  this.LabMedInfo.kbrange = mgval;
              });
          } else if (!!nyval) {
              this.$nextTick(() => {
                  this.LabMedInfo.kbrange = nyval;
              });
          } else {
              this.LabMedInfo.kbrange="";
          }
      },
      //自动获取mic参考范围
      getmicvalue() {
          let nyval = "";
          let mgval = "";
          if (this.LabMedInfo.micny) {
              nyval = ">=" + this.LabMedInfo.micny;
          }
          if (this.LabMedInfo.micmg) {
              mgval = "<=" + this.LabMedInfo.micmg;
          }
          if (mgval && nyval) {
              this.$nextTick(() => {
                  if(this.kbrange){
                      this.LabMedInfo.micrange=this.micrange.replace("#S",this.LabMedInfo.micmg).replace("#R",this.LabMedInfo.micny);
                  }else {
                      this.LabMedInfo.micrange = mgval + ";" + nyval ;
                  }
              });
          } else if (mgval && !nyval) {
              this.$nextTick(() => {
                  this.LabMedInfo.micrange = mgval;
              });
          } else if (nyval && !mgval) {
              this.$nextTick(() => {
                  this.LabMedInfo.micrange = nyval;
              });
          } else {
              this.LabMedInfo.micrange = "";
          }
      },
      btnSortList() {
          this.SortShowData();
      },
      SortShowData() {
          this.xTable1loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "SortShowData",
                  },
              })
              .then((response) => {
                  this.tableData1 = response;
                  this.$nextTick(() => {
                      if (this.$refs.xTable1) {
                          if (this.tableData1.length > 0) {
                              this.$refs.xTable1.setCurrentRow(response[0]);
                          }
                      }
                  });
                  this.SortinnerVisible = true;
                  this.xTable1loading = false;
              })
              .catch((e) => {
                  this.loading = false;
                  this.xTable1loading = false;
                  console.log("error", e);
              });
      },
      SortCurrentChangeEvent({ row, rowIndex }) {
          this.currRowIndex = rowIndex;
      },
      cellClassName({ column }) {
          if (column.property == "seq") {
              if (this.inputseq == "1") {
                  return "";
              } else {
                  return "col-orange";
              }
          } else {
              return "";
          }
      },
      cellinputseq({ row, column }) {
          if (column.property == "seq") {
              if (this.inputseq == "1") {
                  return true;
              } else {
                  return false;
              }
          } else {
              return false;
          }
      },
      funSortListSave() {
          let xTable1date = this.$refs.xTable1.tableData; //主表修改
          if (this.inputseq == "1") {
              //勾选则排序保存
              xTable1date.sort((a, b) => {
                  let groupseq1 = a.groupseq;
                  let groupseq2 = b.groupseq;
                  if (groupseq1 != groupseq2) {
                      return a.groupseq - b.groupseq;
                  } else {
                      return a.seq - b.seq;
                  }
              });
              for (let i = 0, len = xTable1date.length; i < len; i++) {
                  let tempseq = (i + 1) * 10;
                  if (tempseq !== xTable1date[i].seq) {
                      xTable1date[i].seq = tempseq;
                  }
              }
          } else {
              //未勾选则循环保存
              xTable1date.sort((a, b) => {
                  return a.groupseq - b.groupseq;
              });
              for (let i = 0, len = xTable1date.length; i < len; i++) {
                  xTable1date[i].seq = (i + 1) * 10;
              }
          }
          let xTable1datefullData = this.$refs.xTable1.getRecordset();
          this.SortinnerVisible = false;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "funSortListSave",
                      urec: xTable1datefullData,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$pub.message(this, "操作成功！", "success");
                      this.currRowIndex = 0;
                      this.InitPage();
                  } else {
                      this.$alert("保存失败！" + response.errmsg, "提示");
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      SortCancel() {
          this.SortinnerVisible = false;
          this.currRowIndex = 0;
      },
      tabledataup() {
          if (this.currRowIndex > 0) {
              let upData = this.$refs.xTable1.tableData[this.currRowIndex - 1];
              let currentrow = this.$refs.xTable1.tableData[this.currRowIndex];
              this.$refs.xTable1.tableData.splice(this.currRowIndex - 1, 1);
              this.$refs.xTable1.tableData.splice(this.currRowIndex, 0, upData);
              this.currRowIndex = this.currRowIndex - 1;
              this.$nextTick(() => {
                  this.$refs.xTable1.setCurrentRow(currentrow);
              });
          }
      },
      tabledatadown() {
          if (this.currRowIndex !== this.$refs.xTable1.tableData.length - 1) {
              let downData = this.$refs.xTable1.tableData[this.currRowIndex + 1];
              let currentrow = this.$refs.xTable1.tableData[this.currRowIndex];
              this.$refs.xTable1.tableData.splice(this.currRowIndex + 1, 1);
              this.$refs.xTable1.tableData.splice(this.currRowIndex, 0, downData);
              this.currRowIndex = this.currRowIndex + 1;
              this.$nextTick(() => {
                  this.$refs.xTable1.setCurrentRow(currentrow);
              });
          }
      },
      tabledatalast() {
          if (this.currRowIndex != this.$refs.xTable1.tableData.length - 1) {
              let lastData = this.$refs.xTable1.tableData[this.currRowIndex];
              this.$refs.xTable1.tableData.splice(this.currRowIndex, 1);
              this.$refs.xTable1.tableData.splice(this.$refs.xTable1.tableData.length, 0, lastData);
              this.currRowIndex = this.$refs.xTable1.tableData.length - 1;
              this.$nextTick(() => {
                  this.$refs.xTable1.setCurrentRow(lastData);
              });
          }
      },
      tabledatafirst() {
          if (this.currRowIndex > 0) {
              let firstData = this.$refs.xTable1.tableData[this.currRowIndex];
              this.$refs.xTable1.tableData.splice(this.currRowIndex, 1);
              this.$refs.xTable1.tableData.splice(0, 0, firstData);
              this.currRowIndex = 0;
              this.$nextTick(() => {
                  this.$refs.xTable1.setCurrentRow(firstData);
              });
          }
      },
      ddlInitialList() {
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "ddlInitialList",
                  },
              })
              .then((res) => {
                  this.ExternalCode1Option = res.externalcode1;
                  this.ExternalCode2Option = res.externalcode2;
                  this.ExternalCode3Option = res.externalcode3;
                  this.guidelinesList = res.guidelines;
                  this.testmethodList = res.testmethod;
                  this.whonetResistOption = res.whonetResistOption;
                  this.micrange = res.micrange;
                  this.kbrange = res.kbrange;
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      QueryData() {
          this.AddData = [];
          this.ModData = [];
          this.InitPage();
      },
      InitPage() {
          //查询
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "query",
                      txtsearch: this.txtsearch,
                  },
              })
              .then((res) => {
                  if (res.Data.length > 0) {
                      this.labMedData = res.Data;
                      this.selrow = res.Data[0];
                      this.queryRight(res.Data[0]);
                      this.$refs.xTable.setCurrentRow(res.Data[0]);
                      this.havedata = true;
                  } else {
                      this.labMedData = [];
                      this.LabMedInfo = {};
                      this.labmedref = [];
                      this.havedata = false;
                      this.medcode = "";
                      this.message = "";
                  }
                  this.loading = false;
              })
              .catch((e) => {
                  this.loading = false;
                  console.log("error", e);
              });
      },
      btnAddList() {
          this.dismedcode = false;
          this.changeflag = true;
          this.havedata = true;
          this.activeName = "first";
          this.operatetype = "1";
          this.LabMedInfo = {
              medcode: "",
              statcode: "",
              medname: "",
              stopflag: "",
              medname_en: "",
              medconc: "",
              inputcode: "",
              kbny: "",
              kbmg: "",
              micny: "",
              micmg: "",
              kbrange: "",
              micrange: "",
              whocode: "",
              whocode_kb: "",
              whocode_mic: "",
              whocode_etest: "",
              medconc_blood: "",
              medconc_urine: "",
              dosage1: "",
              dosage2: "",
              dosage3: "",
              externalcode1: "",
              externalcode2: "",
              externalcode3: "",
              whonetcolidx: 0,
              seq: 0,
              noprintrule: "",
              note: "",
              medclass2code: "",
              medclass2name: "",
              medclass3code: "",
              medclass3name: "",
              ecvs: "",
              i2sdd: "",
              guidelines: "",
              kbzj: "",
              isimportant:"",
          };
          this.labmedref = [];
          this.$refs.psetTable.clearData();
          setTimeout(() => {
              this.$refs.autofocus1.focus();
          }, 10);
      },
      getinputcode() {
          let that = this;
          if (!that.LabMedInfo.medname) {
              that.LabMedInfo.inputcode = "";
          } else {
              that.LabMedInfo.inputcode = that.$pub.CreateInputcode(that.LabMedInfo.medname, that, 20);
          }
      },
      //主表删除
      btnRemoveList() {
          var delrow = this.$refs.xTable.getCurrentRow();
          if (delrow) {
              let msg = "确定删除该条记录吗？";
              if (!!this.message) msg = "<span class='el-icon-info'>确定删除药物名称为<b style='color:red'>" + this.message + "</b>的记录吗？</span>";
              this.$confirm(msg, "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                  dangerouslyUseHTMLString: true,
              })
                  .then(() => {
                      var alld = this.$refs.xTable.getTableData().fullData;
                      var rowindex = alld.indexOf(delrow);
                      this.$tool
                          .request({
                              url: "LIS/LIS8/LIS820",
                              method: "post",
                              data: {
                                  action: "del",
                                  medcode: this.medcode,
                                  oldinfo: this.LabMedInfo,
                              },
                          })
                          .then((res) => {
                              if (res.errcode == "1") {
                                  this.$refs.xTable.remove(delrow);
                                  this.$pub.message(this, "删除成功！", "success", "2000");
                                  let havedata = this.$refs.xTable.getTableData().fullData;
                                  if (havedata.length > 0) {
                                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                                      let selectrow = havedata[rowindex];
                                      this.$refs.xTable.setCurrentRow(selectrow);
                                      this.queryRight(selectrow);
                                  } else {
                                      this.$refs.xTable.setCurrentRow(null);
                                      this.queryRight(null);
                                  }
                              } else {
                                  this.$alert("删除失败！" + res.errmsg, "提示");
                              }
                          })
                          .catch((e) => {
                              this.$alert(e, "提示");
                          });
                  })
                  .catch(() => {});
          } else {
              this.$alert("请先选中要删除的数据！", "提示");
          }
      },
      saveRecord() {
          //新增，修改保存
          if (this.LabMedInfo.medcode == "") {
              this.$message({
                  message: "请填写药物代码",
                  type: "warning",
                  showClose: true,
              });
              return false;
          }
          if (this.LabMedInfo.medname == "") {
              this.$message({
                  message: "请填写药物代码",
                  type: "warning",
                  showClose: true,
              });
              return false;
          }
          if (this.LabMedInfo.statcode == "") {
              this.$message({
                  message: "请填写统计代码",
                  type: "warning",
                  showClose: true,
              });
              return false;
          }
          let data = this.$refs.psetTable.tableData;
          let fdata = data.filter((m) => !m.orgcode);
          if (fdata.length > 0) {
              this.$alert("请选择细菌代码！", "提示");
              return false;
          }
          fdata = data.filter((m) => !m.testmethod);
          if (fdata.length > 0) {
              this.$alert("请选择测试方法！", "提示");
              return false;
          }
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "saveRecord",
                      uptinfo: this.LabMedInfo,
                      oldinfo: this.oldLabMedInfo,
                      utype: this.operatetype,
                      labmedrefstr: this.$refs.psetTable.getRecordset(),
                  },
              })
              .then((res) => {
                  if (res.errcode == "1") {
                      this.changeflag = false;
                      this.$pub.message(this, "保存成功！", "success");
                      this.medcode = res.keyid[0].medcode;
                      if (this.operatetype == "1") {
                          if (this.AddData.indexOf(this.medcode) == -1) {
                              this.AddData.push(this.medcode);
                          }
                          this.$refs.xTable.insert(res.keyid[0]).then(({ row }) => {
                              setTimeout(() => {
                                  this.$refs.xTable.setCurrentRow(row);
                                  this.$refs.xTable.scrollToRow(row);
                                  this.queryRight(row);
                              }, 10);
                          });
                      } else if (this.operatetype == "2") {
                          if (this.ModData.indexOf(this.medcode) == -1) {
                              this.ModData.push(this.medcode);
                          }
                          this.$nextTick(async () => {
                              this.SetValToTable(res.keyid[0]).then((row) => {
                                  setTimeout(() => {
                                      this.$refs.xTable.setCurrentRow(row);
                                      this.$refs.xTable.scrollToRow(row);
                                  }, 10);
                                  this.queryRight(row);
                              });
                          });
                      }
                  } else {
                      this.$alert("保存失败！" + res.errmsg, "提示");
                  }
              })
              .catch((e) => {
                  console.log(e);
              });
      },
      SetValToTable(row) {
          return new Promise((resolve) => {
              this.selrow.medcode = row.medcode;
              this.selrow.statcode = row.statcode;
              this.selrow.medname = row.medname;
              this.selrow.stopflag = row.stopflag;
              this.selrow.medname_en = row.medname_en;
              this.selrow.medconc = row.medconc;
              this.selrow.inputcode = row.inputcode;
              this.selrow.kbny = row.kbny;
              this.selrow.kbmg = row.kbmg;
              this.selrow.micny = row.micny;
              this.selrow.micmg = row.micmg;
              this.selrow.kbrange = row.kbrange;
              this.selrow.micrange = row.micrange;
              this.selrow.whocode = row.whocode;
              this.selrow.whocode_kb = row.whocode_kb;
              this.selrow.whocode_mic = row.whocode_mic;
              this.selrow.whocode_etest = row.whocode_etest;
              this.selrow.medconc_blood = row.medconc_blood;
              this.selrow.medconc_urine = row.medconc_urine;
              this.selrow.dosage1 = row.dosage1;
              this.selrow.dosage2 = row.dosage2;
              this.selrow.dosage3 = row.dosage3;
              this.selrow.externalcode1 = row.externalcode1;
              this.selrow.externalcode2 = row.externalcode2;
              this.selrow.externalcode3 = row.externalcode3;
              this.selrow.whonetcolidx = row.whonetcolidx;
              this.selrow.seq = row.seq;
              this.selrow.noprintrule = row.noprintrule;
              this.selrow.note = row.note;
              this.selrow.medclass2code = row.medclass2code;
              this.selrow.medclass2name = row.medclass2name;
              this.selrow.medclass3code = row.medclass3code;
              this.selrow.medclass3name = row.medclass3name;
              this.selrow.ecvs = row.ecvs;
              this.selrow.i2sdd = row.i2sdd;
              this.selrow.guidelines = row.guidelines;
              this.selrow.whonetresname = row.whonetresname;
              this.selrow.whonetrescode = row.whonetrescode;
              resolve(this.selrow);
          });
      },
      queryRight(row) {
          if (!!row) {
              this.message = row.medname;
              this.medcode = row.medcode;
              this.dismedcode = true;
              this.operatetype = "2";
              this.$tool
                  .request({
                      url: "LIS/LIS8/LIS820",
                      method: "post",
                      data: {
                          action: "querylabmedref",
                          medcode: row.medcode,
                      },
                  })
                  .then((res) => {
                      this.labmedref = res.labmedref;
                      if (res.labmedref.length > 0) {
                          this.$refs.psetTable.setCurrentRow(res.labmedref[0]);
                      } else {
                          this.$refs.psetTable.setCurrentRow(null);
                      }

                      this.LabMedInfo = res.labmed[0];
                      this.oldLabMedInfo = XEUtils.clone(this.LabMedInfo, true);
                  })
                  .catch((e) => {
                      this.$alert(e, "出错");
                  });
          } else {
              this.labmedref = [];
              this.LabMedInfo = {};
              this.labMedData = [];
          }
      },
      currentChangeEvent({ row, rowIndex }) {
          //行选中
          if (this.changeflag) {
              this.$refs.xTable.setCurrentRow(this.selrow);
              return false;
          } else {
              this.selrow = row;
              this.queryRight(row);
          }
      },
      btnExportCsv() {
          //导出
          this.$refs.xTable.exportCsv({
              filename: "LIS820 抗生素字典",
          });
      },
      btnImportCsv() {
          this.whonetParam.guidelines = "CLSI18";
          this.initGuidelinesList();
          this.WhonetVisible = true;
      },
      rowClassName({ row, rowIndex }) {
          if (row.stopflag == "1") {
              return "rm-alert";
          }
          if (this.AddData.indexOf(row.medcode) > -1) {
              return "row-new";
          }
          if (this.ModData.indexOf(row.medcode) > -1) {
              return "row-modify";
          }
      },
      //自动创建whonet数据
      autoGetData() {
          this.$nextTick(() => {
              this.LabMedInfo.whocode = this.LabMedInfo.medcode;
              if (this.LabMedInfo.medcode) {
                  this.LabMedInfo.whocode_kb = this.LabMedInfo.medcode + "_ND";
                  this.LabMedInfo.whocode_mic = this.LabMedInfo.medcode + "_NM";
                  this.LabMedInfo.whocode_etest = this.LabMedInfo.medcode + "_NE";
              } else {
                  this.LabMedInfo.whocode_kb = "";
                  this.LabMedInfo.whocode_mic = "";
                  this.LabMedInfo.whocode_etest = "";
              }
              this.LabMedInfo.statcode = this.LabMedInfo.medcode;
          });
      },
      Funautofocus(element) {
          if (element == "autofocus1") {
              this.$refs.autofocus2.focus();
          } else if (element == "autofocus2") {
              this.$refs.autofocus3.focus();
          } else if (element == "autofocus3") {
              this.$refs.autofocus4.focus();
          } else if (element == "autofocus4") {
              this.$refs.autofocus5.focus();
          } else if (element == "autofocus5") {
              this.$refs.autofocus6.focus();
          } else if (element == "autofocus6") {
              this.$refs.autofocus7.focus();
          } else if (element == "autofocus7") {
              this.$refs.autofocus8.focus();
          } else if (element == "autofocus8") {
              this.$refs.autofocus9.focus();
          } else if (element == "autofocus9") {
              this.$refs.autofocus10.focus();
          } else if (element == "autofocus10") {
              this.$refs.autofocus10.blur();
              this.$refs.autofocus11.focus();
          } else if (element == "autofocus11") {
              this.$refs.autofocus12.focus();
          } else if (element == "autofocus12") {
              this.$refs.autofocus13.focus();
          } else if (element == "autofocus13") {
              this.$refs.autofocus14.focus();
          } else if (element == "autofocus14") {
              this.$refs.autofocus15.focus();
          } else if (element == "autofocus15") {
              this.$refs.autofocus15.blur();
              this.$refs.autofocus16.focus();
          } else if (element == "autofocus16") {
              this.$refs.autofocus16.blur();
              this.$refs.autofocus17.focus();
          } else if (element == "autofocus17") {
              this.$refs.autofocus17.blur();
              this.$refs.autofocus18.focus();
          } else if (element == "autofocus18") {
              this.$refs.autofocus19.focus();
          } else if (element == "autofocus19") {
              this.$refs.autofocus20.focus();
          } else if (element == "autofocus20") {
              this.$refs.autofocus21.focus();
          } else if (element == "autofocus21") {
              this.$refs.autofocus22.focus();
          } else if (element == "autofocus22") {
              this.$refs.autofocus23.focus();
          } else if (element == "autofocus23") {
              this.$refs.autofocus24.focus();
          } else if (element == "autofocus24") {
              this.$refs.autofocus25.focus();
          } else if (element == "autofocus25") {
              this.$refs.autofocus26.focus();
          } else if (element == "autofocus26") {
              this.$refs.autofocus27.focus();
          } else if (element == "autofocus27") {
              this.$refs.autofocus28.focus();
          } else if (element == "autofocus28") {
              this.$refs.autofocus29.focus();
          } else if (element == "autofocus29") {
              this.$refs.autofocus29.blur();
              this.$refs.autofocus30.focus();
          } else if (element == "autofocus30") {
              this.$refs.autofocus31.focus();
          } else if (element == "autofocus31") {
              this.$refs.autofocus32.focus();
          } else if (element == "autofocus32") {
              this.$refs.autofocus33.focus();
          } else if (element == "autofocus33") {
              this.$refs.autofocus34.focus();
          } else if (element == "autofocus34") {
              this.$refs.autofocus35.focus();
          } else if (element == "autofocus35") {
              this.$refs.autofocus36.$el.focus();
          } else if (element == "autofocus36") {
              this.$refs.autofocus37.$el.focus();
          } else {
              this.saveRecord();
          }
      },
      handleClick(tab, event) {
          if (tab.name == "second") {
              this.labmedrefkey++;
          }
      },
      //折点Tab操作方法
      OpenDialog(type) {
          if (type == 1) {
              let isimp=this.LabMedInfo.isimportant=="1"?"1":"0";
              this.$refs.psetTable
                  .insert({
                      medcode: this.LabMedInfo.medcode,
                      specimen_code:"All",
                      isimportant:isimp,
                  })
                  .then(({ row }) => {
                      this.$refs.psetTable.setCurrentRow(row).then(() => {
                          this.$refs.psetTable.scrollToRow(row);
                      });
                      this.changeflag = true;
                  });
          } else if (type == 2) {
              try {
                  var delrow = this.$refs.psetTable.getCurrentRow();
                  if (delrow) {
                      var alld = this.$refs.psetTable.tableData;
                      var rowindex = alld.indexOf(delrow);
                      this.$refs.psetTable.remove(delrow);
                      let havedata = this.$refs.psetTable.tableData;
                      if (havedata.length > 0) {
                          if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                          let selectrow = havedata[rowindex];
                          this.$refs.psetTable.setCurrentRow(selectrow);
                      } else {
                          this.$refs.psetTable.setCurrentRow(null);
                      }
                      this.changeflag = true;
                  }
              } catch (e) {
                  this.$alert(e, "error");
              }
          } else if (type == 4) {
              this.querywhodruglist1();
              this.whoDrugVisible = true;
          }
      },
      querywhodruglist1() {
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "querywhodruglist1",
                      medcode: this.LabMedInfo.medcode,
                  },
              })
              .then((res) => {
                  this.fwhoDrugList = XEUtils.clone(res.bactwhodruglist1, true);
                  // this.whoDrugList = res.bactwhodruglist1;
                  this.filterWhodrugChange();
              })
              .catch((e) => {
                  console.log(e);
              });
      },
      dbLab_medref({ row, column }) {
          if (column.property == "orgcode") {
              this.detailrow = row;
              this.rptitemgermVisible = true;
          }
      },
      testMethodChange({ row }, e) {
          row.testmethod = e.target.value;
          this.hasChange();
      },
      geramSelect(c, v, row) {
          this.detailrow.orgcode = c;
          this.detailrow.rpt_itemname = v;
          if (this.geramradio == 1) {
              //菌科
              this.detailrow.isgermgroup = "2";
              this.detailrow.isgermkind = "1";
          } else if (this.geramradio == 2) {
              //菌属
              this.detailrow.isgermgroup = "1";
              this.detailrow.isgermkind = "";
          } else {
              //细菌
              this.detailrow.isgermgroup = "0";
              this.detailrow.isgermkind = "";
          }
          this.hasChange();
          this.rptitemgermVisible = false;
          this.isimportantmed(c);
      },
      isimportantmed(c){
          if(this.detailrow.isimportant=="1") return false;//抗生素主表已是1，新增时已赋值为1。
          let alldata= this.$refs.psetTable.getTableData().fullData;
          //菌科
          if(this.geramradio == "1"){
              if(alldata.filter((item)=> item.orgcode==c && item.isimportant=='1').length>0){
                  this.detailrow.isimportant='1';
              }
          }else{//菌属 细菌
              this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "isimportantmed",
                      medcode: this.LabMedInfo.medcode,
                      isgermgroup:this.detailrow.isgermgroup,
                      rpt_itemcode:this.detailrow.orgcode,
                  },
              })
              .then((res) => {
                  if(res.errcode=="1"){
                      this.detailrow.isimportant=res.isimportant;
                  }else{
                      this.detailrow.isimportant="0";
                  }
              })
              .catch((e) => {
                  console.log(e);
              });
          }
      },
      guidelinesChange(event) {
          if (this.$refs.whoneTable && this.$refs.whoneTable.getSelectRecords().length > 0) {
              this.$confirm("是否保存之前的操作?", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
              })
                  .then(() => {
                      // 保存重置
                      this.saveLabmed();
                      if (!this.saveflag) return false;
                      this.whoDrugField = {
                          KBNY: event.toLowerCase() + "_dr",
                          Kbzj: event.toLowerCase() + "_di",
                          Kbmg: event.toLowerCase() + "_ds",
                          Micny: event.toLowerCase() + "_mr",
                          Micmg: event.toLowerCase() + "_ms",
                      };
                  })
                  .catch(() => {
                      // 重置
                      this.initGuidelinesList();
                  });
          } else {
              this.initGuidelinesList();
          }
      },
      selectChangeEvent({ checked, row }) {
          // 取消不做任何操作，最后不保存
          if (!checked) return false;
          // 根据whon5code列的取值到抗生素表lab_med中根据抗生素代码检索
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "querylabmed",
                      whon5code: row.whon5_code,
                  },
              })
              .then((res) => {
                  if (res.item != null && res.item != undefined) {
                      row.dealname = "更新";
                      row.statcode = res.item.statcode;
                  } else {
                      row.dealname = "新增";
                  }
                  this.$refs.whoneTable.updateData();
              })
              .catch((e) => {
                  console.log(e);
              });
      },
      filterData() {
          var filterName = this.whonetParam.filterParam.trim();
          let queryList = [];
          if (filterName) {
              this.fwhonetList.filter((item) => {
                  if (item.antibiotic.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || item.whon5_code.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || item.antibiotic_cn.toUpperCase().indexOf(filterName.toUpperCase()) > -1) {
                      queryList.push(item);
                  }
              });
              this.whonetList = queryList;
          } else {
              this.whonetList = XEUtils.clone(this.fwhonetList, true);
          }
      },
      saveLabmed() {
          this.saveflag = false;
          var labmedObj = this.$refs.whoneTable.getSelectRecords();
          if (labmedObj.length == 0) {
              this.$message.error("请先选择要保存的内容！");
              return false;
          }
          var updateRecords = [];
          var insertRecords = [];
          labmedObj.forEach((element) => {
              element.medcode = element.statcode;
              if (element.dealname == "新增") {
                  insertRecords.push({
                      medcode: element.medcode,
                      statcode: element.medcode,
                      medname: element.antibiotic_cn,
                      medname_en: element.antibiotic,
                      whocode: element.whon5_code,
                      whocode_kb: element.whon5_code + "_ND",
                      whocode_mic: element.whon5_code + "_NM",
                      whocode_etest: element.whon5_code + "_NE",
                      kbny: element.kbny,
                      kbzj: element.kbzj,
                      kbmg: element.kbmg,
                      micny: element.micny,
                      micmg: element.micmg,
                  });
              }
              if (element.dealname == "更新") {
                  updateRecords.push({
                      medcode: element.medcode,
                      kbny: element.kbny,
                      kbzj: element.kbzj,
                      kbmg: element.kbmg,
                      micny: element.micny,
                      micmg: element.micmg,
                  });
              }
          });
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "savelabmed",
                      updateRecords: updateRecords,
                      insertRecords: insertRecords,
                  },
              })
              .then((res) => {
                  if (res.errcode == 1) {
                      this.saveflag = true;
                      this.$message.success(res.errmsg);
                      // 重置
                      this.initGuidelinesList();
                  } else {
                      this.$message.error(res.errmsg);
                  }
              })
              .catch((e) => {
                  console.log(e);
              });
      },
      cancelLabmed() {
          this.WhonetVisible = false;
          this.InitPage();
      },
      filterWhodrugChange() {
          var guidelines = this.whodrugParam.guidelines.trim();
          var testmethod = this.whodrugParam.testmethod ? this.whodrugParam.testmethod.trim() : "";
          var orgcode = this.whodrugParam.orgcode ? this.whodrugParam.orgcode.trim() : "";
          let queryList = [];
          if (guidelines || testmethod || orgcode) {
              this.fwhoDrugList.filter((item) => {
                  if (item.guidelines.toUpperCase() == guidelines.toUpperCase()) {
                      if (item.testmethod.toUpperCase().indexOf(testmethod.toUpperCase()) > -1 && item.org_code.toUpperCase().indexOf(orgcode.toUpperCase()) > -1) {
                          queryList.push(item);
                      }
                  }
              });
              this.whoDrugList = queryList;
          } else {
              this.whoDrugList = XEUtils.clone(this.fwhoDrugList, true);
          }
      },
      saveWhodrug() {
          var importList = this.$refs.whoneDrugTable.getSelectRecords();
          if (importList.length == 0) {
              this.$message.error("请选择要导入的抗生素折点！");
              return false;
          }
          // 保存
          importList.forEach((element) => {
              element.medcode = this.LabMedInfo.medcode;
              element.orgcode = element.org_code;
          });
          var labmedrefstr = this.$refs.psetTable.getTableData().fullData.concat(importList);
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS820",
                  method: "post",
                  data: {
                      action: "labmedrefupdate",
                      medcode: this.LabMedInfo.medcode,
                      labmedrefstr: labmedrefstr,
                  },
              })
              .then((res) => {
                  if (res.errcode == 1) {
                      this.$message.success("保存成功！");
                      this.whoDrugVisible = false;
                      this.queryRight(this.LabMedInfo);
                  } else {
                      this.$message.error("错误：" + res.errmsg);
                  }
              })
              .catch((e) => {
                  console.log(e);
              });
      },
      cancelWhodrug() {
          this.whoDrugVisible = false;
      },
      orgCodeChange(c, v) {
          this.whodrugParam.orgcode = c;
          this.whodrugParam.orgname = v;
          this.filterWhodrugChange();
      },
      //主表列颜色
      labmedcellClassName({ columnIndex, row }) {
          if (columnIndex == 0) {
              return this.$pub.diseditcolumn();
          }
      },
      //折点颜色
      RowClassName({ row, rowIndex }) {
          let isDirty = this.$refs.psetTable.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.psetTable.hasRowInsert(row)) return "row-new";
      },
      //折点细菌弹窗，菌科菌属细菌的切换
      geramradioChange() {
          if (this.geramradio == "1") {
              this.datetype = "labgermkind";
              this.datetitle = "请选择菌科";
              this.popkey++;
          } else if (this.geramradio == "2") {
              this.datetype = "germgroup";
              this.datetitle = "请选择菌属";
              this.popkey++;
          } else {
              this.datetype = "rptitemgermflag2";
              this.datetitle = "请选择细菌";
              this.popkey++;
          }
      },
      //顶部取消按钮
      btnCancel() {
          this.changeflag = false;
          this.queryRight(this.selrow);
      },
      //检测基本信息是否改变
      hasChange(param) {
          this.changeflag = true;
          if (param == "medcode") {
              this.autoGetData();
          }
      },
      calcMedRange(column){
          var field=column;
          if(field == "kbny" || field == "kbmg"){
              var kbny="";
              var kbmg="";
              var havesym = false;//输入的值是否带符号
              if(!!this.LabMedInfo.kbny){
                  if(this.LabMedInfo.kbny.indexOf('>')>-1 || this.LabMedInfo.kbny.indexOf('<')>-1 || this.LabMedInfo.kbny.indexOf('=')>-1)
                  {
                      kbny=this.LabMedInfo.kbny;
                      havesym=true;
                  }else{
                      kbny="<="+this.LabMedInfo.kbny;
                  }
              }
              if(!!this.LabMedInfo.kbmg){
                  if(this.LabMedInfo.kbmg.indexOf('>')>-1 || this.LabMedInfo.kbmg.indexOf('<')>-1 || this.LabMedInfo.kbmg.indexOf('=')>-1)
                  {
                      kbmg=this.LabMedInfo.kbmg;
                      havesym=true;
                  }else{
                      kbmg=">="+this.LabMedInfo.kbmg;
                  }
              }
              if(!!kbny && !!kbmg){
                  if(this.kbrange){
                      if(havesym){
                          this.LabMedInfo.kbrange=this.kbrange.replace(">=#S",kbmg).replace("<=#R",kbny);
                      }else{
                          this.LabMedInfo.kbrange=this.kbrange.replace("#S",this.LabMedInfo.kbmg).replace("#R",this.LabMedInfo.kbny);
                      }
                  }else{
                      this.LabMedInfo.kbrange=kbmg+";"+kbny;
                  }
              }else if(!!kbny){
                  this.LabMedInfo.kbrange=kbny ;
              }else if (!!kbmg){
                  this.LabMedInfo.kbrange=kbmg ;
              }else{
                  this.LabMedInfo.kbrange="" ;
              }
          }
          if(field=="micny" || field=="micmg"){
              var micny="";
              var micmg="";
              var havesym = false;//输入的值是否带符号
              if(!!this.LabMedInfo.micny){
                  if(this.LabMedInfo.micny.indexOf('>')>-1 || this.LabMedInfo.micny.indexOf('<')>-1 || this.LabMedInfo.micny.indexOf('=')>-1)
                  {
                      micny=this.LabMedInfo.micny;
                      havesym=true;
                  }else{
                      micny=">="+this.LabMedInfo.micny;
                  }
              }
              if(!!this.LabMedInfo.micmg){
                  if(this.LabMedInfo.micmg.indexOf('>')>-1 || this.LabMedInfo.micmg.indexOf('<')>-1 || this.LabMedInfo.micmg.indexOf('=')>-1)
                  {
                      micmg=this.LabMedInfo.micmg;
                      havesym=true;
                  }else{
                      micmg="<="+this.LabMedInfo.micmg;
                  }
              }
              if(!!micny && !!micmg){
                  if(this.micrange){
                      if(havesym){
                          this.LabMedInfo.micrange=this.micrange.replace(">=#S",micmg).replace("<=#R",micny);
                      }else{
                          this.LabMedInfo.micrange=this.micrange.replace("#S",this.LabMedInfo.micmg).replace("#R",this.LabMedInfo.micny);
                      }
                  }else{
                      this.LabMedInfo.micrange=micmg+";"+micny;
                  }
              }else if(!!micny){
                  this.LabMedInfo.micrange=micny ;
              }else if (!!micmg){
                  this.LabMedInfo.micrange=micmg ;
              }else{
                  this.LabMedInfo.micrange="" ;
              }
          }
          this.hasChange();
      },

      CalcRange(val,row,column){
          var secval= val;
          var field=column;
          if(field=="kbny") row.kbny=secval;
          if(field=="kbmg") row.kbmg=secval;
          if(field=="micny") row.micny=secval;
          if(field=="micmg") row.micmg=secval;
          if(field=="kbny" || field=="kbmg"){
              var kbny="";
              var kbmg="";
              var havesym = false;//输入的值是否带符号
              if(!!row.kbny){
                  if(row.kbny.indexOf('>')>-1 || row.kbny.indexOf('<')>-1 || row.kbny.indexOf('=')>-1)
                  {
                      kbny=row.kbny;
                      havesym=true;
                  }else{
                      kbny="<="+row.kbny;
                  }
              }
              if(!!row.kbmg){
                  if(row.kbmg.indexOf('>')>-1 || row.kbmg.indexOf('<')>-1 || row.kbmg.indexOf('=')>-1)
                  {
                      kbmg=row.kbmg;
                      havesym=true;
                  }else{
                      kbmg=">="+row.kbmg;
                  }
              }
              if(!!kbny && !!kbmg){
                  if(this.kbrange){
                      if(havesym){
                          row.kbrange=this.kbrange.replace(">=#S",kbmg).replace("<=#R",kbny);
                      }else{
                          row.kbrange=this.kbrange.replace("#S",row.kbmg).replace("#R",row.kbny);
                      }
                  }else{
                      row.kbrange=kbmg+";"+kbny;
                  }
              }else if(!!kbny){
                  row.kbrange=kbny ;
              }else if (!!kbmg){
                  row.kbrange=kbmg ;
              }else{
                  row.kbrange="" ;
              }
          }
          if(field=="micny" || field=="micmg"){
              var micny="";
              var micmg="";
              var havesym = false;//输入的值是否带符号
              if(!!row.micny){
                  if(row.micny.indexOf('>')>-1 || row.micny.indexOf('<')>-1 || row.micny.indexOf('=')>-1)
                  {
                      micny=row.micny;
                      havesym=true;
                  }else{
                      micny=">="+row.micny;
                  }
              }
              if(!!row.micmg){
                  if(row.micmg.indexOf('>')>-1 || row.micmg.indexOf('<')>-1 || row.micmg.indexOf('=')>-1)
                  {
                      micmg=row.micmg;
                      havesym=true;
                  }else{
                      micmg="<="+row.micmg;
                  }
              }
              if(!!micny && !!micmg){
                  if(this.micrange){
                      if(havesym){
                          row.micrange=this.micrange.replace(">=#S",micmg).replace("<=#R",micny);
                      }else{
                          row.micrange=this.micrange.replace("#S",row.micmg).replace("#R",row.micny);
                      }
                  }else{
                      row.micrange=micmg+";"+micny;
                  }
              }else if(!!micny){
                  row.micrange=micny ;
              }else if (!!micmg){
                  row.micrange=micmg ;
              }else{
                   row.micrange="" ;
              }
          }
          this.hasChange();
      },

      importMed() {
          this.$refs['upload'].$refs['upload-inner'].handleClick();
      },
      uploadOpt(content) {
          let formData = new FormData();
          formData.append("action", "LIS820");
          formData.append("file", content.file);
          var URL = this.$tool.baseUrl.replace("api", "z") + "fileupload";
          axios.post(URL, formData, { "Content-Type": "multipart/form-data" })
              .then(res => {
                  let response = res.data;
                  if (response.flag == 1) {
                      this.$notify.success({
                          title: "成功",
                          message: response.msg,
                      });
                  } else {
                      this.$notify.error({
                          title: "错误",
                          message: response.msg
                      });
                  }
              })
              .catch(e => {
                  this.$alert(e, "出错");
              });
      },
      // 文件状态改变时的钩子
      fileChange(file, fileList) {
          this.form.file = file.raw;
      },
  },
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 35px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 40px;
  width: 100%;
  left: 0;
  bottom: 0px;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 755px;
}

.middle-right {
  position: absolute;
  height: 100%;
  width: 750px;
  right: 0px;
  overflow: auto;
}
.sortbtnstyle {
  padding: 10px;
}
.formtablestyle {
  height: 100%;
  font-size: 12px;
  color: #333;
  width: 100%;
}
.formtablestyle tr td {
  padding: 1px;
}
.formtablestyle tr td:nth-child(1),
td:nth-child(3),
td:nth-child(5) {
  text-align: right;
}
.formtablestyle tr td:nth-child(2),
td:nth-child(4),
td:nth-child(6) {
  width: 130px;
}
/deep/ tr.vxe-body--row.row-new {
  color: #cc6600;
}
/deep/ tr.vxe-body--row.row-modify {
  color: blue !important;
}
.table1style tr td {
  padding: 0px 2px 0px 5px;
}

.whone-top div {
  display: inline-block;
  width: 158px !important;
  margin: 5px 0;
}
/deep/ .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}
/deep/ .whone-top .el-select > .el-input {
  display: inline-block !important;
}
.whone-bottom {
  height: 400px;
}

/deep/.middle-right .formtablestyle tr td div .el-input__inner {
  color: #000000;
  /*font-weight: 800;*/
}
/deep/ .mytable-style.vxe-table .vxe-body--column.col-orange {
  background-color: #f8f8f8;
}

/deep/ .REFmedconc_urine1 .el-input__inner {
  color: red;
}
/deep/ .REFmedconc_urine2 .el-input__inner {
  color: blue;
}
/deep/ .whone-top .input-suffix div {
  width: 350px !important;
}
/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: black;
}
/deep/ .el-tabs--border-card > .el-tabs__content {
  border: 1px solid #ccc;
}
/deep/ tr.vxe-body--row.row--current {
  color: #000000;
  font-weight: bold;
}
/deep/ .labmed-content .vxe-table .vxe-table--empty-block {
  height: auto !important;
}
.upload-button {
  height: 24px;
  margin: 0 10px;
  display: none;
}
.upload-button div {
  height: 24px;
}
/deep/ .upload-button .el-upload--text {
  border: 0 !important;
  border-radius: 3px !important;
}
</style>